﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Npgsql;


namespace EMR
{
    public partial class frm_Login : Form
    {

        private User _user = new User();
        public frm_Login()
        {
            InitializeComponent();
            this.txb_psw.Text = "0729";
            this.txb_UID.Text = "20090729";
        }

        private void btn_Login_Click(object sender, EventArgs e)
        {
            if (this.txb_UID.Text.Trim() == "")                                                  
            {
                MessageBox.Show("用户号不能为空！");                                                
                this.txb_UID.Focus();                                                            
                return;                                                                             
            }
            if (this.txb_psw.Text.Trim() == "")                                              
            {
                MessageBox.Show("密码不能为空！");                                                 
                this.txb_psw.Focus();                                                         
                return;                                                                             
            }
            _user.No = this.txb_UID.Text;
            _user.Password = this.txb_psw.Text;
            if(UserBll.LogIn(_user))
            {
                this.Hide();
                Main mainForm = new Main();
                mainForm.ShowDialog();
                mainForm.StartPosition = FormStartPosition.CenterScreen;
            }
            
        }

       



    }
}
